<?php
/**
 * CompleXml Framework
 *
 * @category   CompleXml
 * @package    CompleXml_Output
 * @copyright  Copyright (c) 2008 Andrey Kucherenko
 * @license    New BSD License
 * @version    $Id: Xml.php 57 2009-10-25 19:38:43Z kucherenko.andrey $
 */
#require_once 'CompleXml/Output/Interface.php';
/**
 * Класс передающий агрегированный XML в браузер без преобразования
 */
class CompleXml_Output_Xml implements CompleXml_Output_Interface {

    public static function execute(CompleXml_Controller $ControllerObject) {
        $settings = CompleXml_Config::readComponentSettings(__CLASS__);
        $is_debug = (boolean) $settings['only_xml'];
        if ((@$_SERVER[ 'HTTP_X_REQUESTED_WITH' ]!='XMLHttpRequest')&&
            !$is_debug){
            return false;
        }
        $xmlString = $ControllerObject->View->getXml();
        $xml = new DomDocument ( );
        $xml->loadXML ( $xmlString );
        @$xml->xinclude ();
        header ( "Content-type: application/xml" );
        echo $xml->saveXML ();
        return true;
    }
}